package com.ObjectCreator;


import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Scanner;

/**
 * ObjectCreator
 *
 * @author iLife.Fy
 */
public class ObjectCreator {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        List<MyObject> myObjects = new ArrayList<>();
        System.out.println("How many object do you want ?");
        int objectNum = Integer.parseInt(scan.nextLine());
        for (int i = 1; i <= objectNum; i++) {
            MyObject myObject = new MyObject();
            System.out.println("Please enter the name of your object number " + i);
            myObject.name = scan.nextLine();
            System.out.println("Please enter the year of birth of your object number " + i);
            int year = Integer.parseInt(scan.nextLine());
            System.out.println("Please enter the month of birth of your object number " + i);
            int month = getMonth(Integer.parseInt(scan.nextLine()));
            System.out.println("Please enter the day of birth of your object number " + i);
            int day = Integer.parseInt(scan.nextLine());
            myObject.birthDate = new MyDate(year, month, day);
            System.out.println("Please enter the height(cm) of birth of your object number " + i);
            myObject.height = Float.parseFloat(scan.nextLine());
            System.out.println("Please enter the weight(kg) of birth of your object number " + i);
            myObject.weight = Float.parseFloat(scan.nextLine());
            myObjects.add(myObject);
        }
        System.out.println("What follows is the details of all your objects!");
        for (MyObject obj : myObjects) {
            System.out.println(obj.toString());
        }
    }

    private static int getMonth(int nextInt) {
        int month;
        switch (nextInt) {
            case 1:
                month = Calendar.JANUARY;
                break;
            case 2:
                month = Calendar.FEBRUARY;
                break;
            case 3:
                month = Calendar.MARCH;
                break;
            case 4:
                month = Calendar.APRIL;
                break;
            case 5:
                month = Calendar.MAY;
                break;
            case 6:
                month = Calendar.JUNE;
                break;
            case 7:
                month = Calendar.JULY;
                break;
            case 8:
                month = Calendar.AUGUST;
                break;
            case 9:
                month = Calendar.SEPTEMBER;
                break;
            case 10:
                month = Calendar.OCTOBER;
                break;
            case 11:
                month = Calendar.NOVEMBER;
                break;
            default:
                month = Calendar.DECEMBER;
                break;
        }
        return month;
    }

    static class MyObject {
        /**
         * name
         */
        public String name;
        /**
         * date of birth
         */
        public MyDate birthDate;
        /**
         * height
         */
        public float height;
        /**
         * weight
         */
        public float weight;

        @Override
        public String toString() {
            return "MyObject { " + "name='" + name + '\'' + ", birthDate=" + birthDate + ", height=" + height + ", weight=" + weight + " }";
        }
    }

    static class MyDate {
        int year;
        int month;
        int day;

        public MyDate(int year, int month, int day) {
            this.year = year;
            this.month = month;
            this.day = day;
        }

        @Override
        public String toString() {
            return year + "-" + month + "-" + day;
        }
    }
}
